let input_start = window.document.getElementById('air-input-start');
let input_end = window.document.getElementById('air-input-end');
let img_start = window.document.getElementById('air-img-start');
let img_end = window.document.getElementById('air-img-end');
let valueOf = document.getElementsByName('csrfmiddlewaretoken')[0].value
let sub = document.getElementById('air-sub');
i = 0;
input_start.onblur = function () {
    $.post('find_city', {
        csrfmiddlewaretoken: valueOf,
        'city': this.value
    }, function (data) {
        if (data.msg === 'true') {
            img_start.hidden = false;
            i++;
            img_start.src = '/static/images/勾.svg';
        } else {
            img_start.hidden = false;
            i--;
            img_start.src = '/static/images/叉.svg';
        }
        sub.disabled = i !== 2;
        if (i < 0)
            i = 0
    })

}
input_end.onblur = function () {
    $.post('find_city', {
        csrfmiddlewaretoken: valueOf,
        'city': this.value
    }, function (data) {
        if (data.msg === 'true') {
            img_end.hidden = false;
            i++;
            img_end.src = '/static/images/勾.svg';
        } else {
            img_end.hidden = false;
            i--;
            img_end.src = '/static/images/叉.svg';
        }
        sub.disabled = i !== 2;
        if (i < 0)
            i = 0
    })
}


